package com.netease.pris.app;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.view.Display;
import android.view.WindowManager;
import com.netease.framework.l;
import com.netease.pris.a.q;
import com.netease.pris.a.t;
import com.netease.pris.activity.PRISServiceOfflineDownload;
import com.netease.pris.activity.di;
import com.netease.pris.v;
import com.netease.update.CheckVersionService;
import dalvik.system.VMRuntime;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;

public class PrisApp extends Application
{
  public static final String c = "/pris/image/";
  private static PrisApp i;
  private static final float j = 0.75F;
  LinkedList a = null;
  com.netease.pris.atom.u b;
  private com.netease.pris.protocol.d d = null;
  private com.netease.pris.protocol.d e = null;
  private com.netease.pris.protocol.d f = null;
  private ArrayList g;
  private boolean h = false;
  private PRISServiceOfflineDownload k = null;
  private ArrayList l = new ArrayList();
  private boolean m;
  private ServiceConnection n = new c(this);

  private void C()
  {
    com.netease.e.b.a(i).a();
  }

  private void D()
  {
    Intent localIntent = new Intent(this, PRISServiceOfflineDownload.class);
    startService(localIntent);
    bindService(localIntent, this.n, 1);
  }

  public static PrisApp a()
  {
    if (i == null)
      throw new NullPointerException("app not create should be terminated!");
    return i;
  }

  public String A()
  {
    return getSharedPreferences("PRISSharePrefs", 0).getString("skin", getPackageName());
  }

  public l B()
  {
    l locall = new l();
    locall.c(getResources().getString(2131362327));
    locall.b("internal.skin.black");
    locall.a(true);
    locall.b("internal.skin.black".equals(A()));
    locall.a(null);
    return locall;
  }

  public void a(Handler paramHandler, Runnable paramRunnable)
  {
    Message localMessage = Message.obtain(paramHandler, paramRunnable);
    if (v())
      localMessage.sendToTarget();
    while (true)
    {
      return;
      x();
      synchronized (this.l)
      {
        this.l.add(localMessage);
      }
    }
  }

  public void a(com.netease.pris.atom.u paramu)
  {
    this.b = paramu;
  }

  public void a(com.netease.pris.offline.e parame)
  {
    if (this.k != null)
      this.k.a(parame);
  }

  public void a(com.netease.pris.protocol.d paramd)
  {
    if (this.f != null)
      this.f = null;
    this.f = paramd;
  }

  public void a(String paramString)
  {
    getSharedPreferences("PRISSharePrefs", 0).edit().putString("skin", paramString).commit();
  }

  public void a(String paramString1, String paramString2, String paramString3)
  {
    int i1 = 0;
    if ((paramString2 == null) || (paramString3 == null));
    File[] arrayOfFile;
    while (true)
    {
      return;
      arrayOfFile = new File(paramString1).listFiles();
      if (arrayOfFile == null)
        continue;
      if ((!paramString2.equals("*")) || (!paramString3.equals("*")))
        break;
      int i3 = arrayOfFile.length;
      while (i1 < i3)
      {
        File localFile2 = arrayOfFile[i1];
        if (!localFile2.isDirectory())
          localFile2.delete();
        i1++;
      }
    }
    int i2 = arrayOfFile.length;
    label92: File localFile1;
    if (i1 < i2)
    {
      localFile1 = arrayOfFile[i1];
      if (!localFile1.isDirectory())
        break label120;
    }
    while (true)
    {
      i1++;
      break label92;
      break;
      label120: if ((paramString2.equals("*")) && (localFile1.getName().endsWith("." + paramString3)))
      {
        localFile1.delete();
        continue;
      }
      if ((paramString3.equals("*")) && (localFile1.getName().startsWith(paramString2)))
      {
        localFile1.delete();
        continue;
      }
      if ((!localFile1.getName().startsWith(paramString2)) || (!localFile1.getName().endsWith("." + paramString3)))
        continue;
      localFile1.delete();
    }
  }

  public void a(ArrayList paramArrayList)
  {
    if ((paramArrayList != null) && (paramArrayList.size() > 0))
    {
      this.g = paramArrayList;
      this.h = true;
    }
  }

  public void a(LinkedList paramLinkedList)
  {
    if (this.a != null)
      this.a = null;
    this.a = paramLinkedList;
  }

  public boolean a(Handler paramHandler)
  {
    a(paramHandler, new d(this));
    return true;
  }

  public void b(com.netease.pris.offline.e parame)
  {
    if (this.k != null)
      this.k.b(parame);
  }

  public void b(com.netease.pris.protocol.d paramd)
  {
    if ((paramd != null) && (this.d != null))
    {
      this.d.k();
      this.d = null;
    }
    this.d = paramd;
  }

  public boolean b()
  {
    if ((Build.DISPLAY != null) && (Build.DISPLAY.contains("simenxie")));
    for (int i1 = 1; ; i1 = 0)
      return i1;
  }

  public void c(com.netease.pris.protocol.d paramd)
  {
    if (this.e != null)
    {
      this.e.k();
      this.e = null;
    }
    this.e = paramd;
  }

  public boolean c()
  {
    return true;
  }

  public ArrayList d()
  {
    return this.g;
  }

  public boolean e()
  {
    return this.h;
  }

  public void f()
  {
    this.g.clear();
    this.g = null;
    this.h = false;
  }

  public void g()
  {
    if (com.netease.pris.a.e.a())
      a(Environment.getExternalStorageDirectory().toString(), "*", "txt");
  }

  public void h()
  {
    String str = i();
    if (str == null);
    while (true)
    {
      return;
      a(str, "*", "*");
    }
  }

  public String i()
  {
    String str;
    if (com.netease.pris.a.e.a())
    {
      str = Environment.getExternalStorageDirectory().toString() + "/pris/image/";
      File localFile = new File(str);
      if (!localFile.exists())
        localFile.mkdirs();
    }
    while (true)
    {
      return str;
      str = getCacheDir().getPath() + "/";
    }
  }

  public boolean j()
  {
    return com.netease.pris.a.u.e(this);
  }

  public String k()
  {
    Object[] arrayOfObject = new Object[5];
    arrayOfObject[0] = com.netease.pris.a.e.b(a().getApplicationContext());
    arrayOfObject[1] = com.netease.pris.a.u.m(this);
    arrayOfObject[2] = q.b();
    arrayOfObject[3] = com.netease.pris.a.u.r(this);
    arrayOfObject[4] = "1.0.1";
    return String.format("pris/%s (%s; android; %s; %s; android) %s", arrayOfObject);
  }

  public String l()
  {
    return com.netease.pris.a.u.g(this);
  }

  public com.netease.pris.protocol.d m()
  {
    return this.f;
  }

  public LinkedList n()
  {
    return this.a;
  }

  public void o()
  {
    if (this.d != null)
    {
      this.d.k();
      this.d = null;
    }
  }

  public void onCreate()
  {
    long l1 = System.currentTimeMillis();
    super.onCreate();
    i = this;
    VMRuntime.getRuntime().setTargetHeapUtilization(0.75F);
    Thread.setDefaultUncaughtExceptionHandler(new f(this));
    com.netease.d.c.a(this);
    com.netease.g.b.a(getPackageName(), "");
    C();
    new com.netease.d.b(this);
    com.netease.pris.b.a.d(System.currentTimeMillis());
    com.netease.b.a.d.h().a(this);
    com.netease.b.a.d.h().a(new di());
    com.netease.pris.d.c.a(com.netease.pris.b.a.b());
    com.netease.b.a.d.h().a(com.netease.pris.b.a.c(), com.netease.pris.b.a.g());
    com.netease.b.a.d.h().a(com.netease.pris.b.a.d());
    v.a().q();
    com.netease.pris.d.c.a(this);
    com.netease.b.a.d.h().m();
    com.netease.pris.d.c.a(System.currentTimeMillis() - l1);
  }

  public void onTerminate()
  {
    super.onTerminate();
  }

  public com.netease.pris.protocol.d p()
  {
    return this.d;
  }

  public com.netease.pris.atom.u q()
  {
    return this.b;
  }

  public com.netease.pris.protocol.d r()
  {
    return this.e;
  }

  public void s()
  {
    com.netease.pris.d.c.a(false);
    com.netease.b.a.d.h().j();
    com.netease.image.d.a().c();
    com.netease.e.b.a(i).b();
    if (this.k != null)
    {
      this.k.stopSelf();
      this.k = null;
    }
    stopService(new Intent(this, CheckVersionService.class));
    new Handler().postDelayed(new a(this), 1000L);
  }

  public int t()
  {
    int i1 = 0;
    t localt = com.netease.pris.a.u.c(this);
    switch (b.a[localt.ordinal()])
    {
    case 5:
    case 6:
    default:
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      return i1;
      i1 = 2;
      continue;
      i1 = 1;
      continue;
      i1 = 3;
    }
  }

  /** @deprecated */
  public void u()
  {
    monitorenter;
    try
    {
      if (this.m)
      {
        if (v())
        {
          this.k.b();
          unbindService(this.n);
          this.k = null;
        }
        stopService(new Intent(this, PRISServiceOfflineDownload.class));
        this.m = false;
      }
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public boolean v()
  {
    if (this.k != null);
    for (int i1 = 1; ; i1 = 0)
      return i1;
  }

  public PRISServiceOfflineDownload w()
  {
    return this.k;
  }

  /** @deprecated */
  public void x()
  {
    monitorenter;
    try
    {
      if ((!this.m) && (this.k == null))
      {
        D();
        this.m = true;
      }
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public boolean y()
  {
    boolean bool;
    if ((this.m) && (!v()))
      bool = true;
    while (true)
    {
      return bool;
      if (!v())
      {
        bool = false;
        continue;
      }
      bool = this.k.c();
    }
  }

  public int[] z()
  {
    Display localDisplay = ((WindowManager)getApplicationContext().getSystemService("window")).getDefaultDisplay();
    int[] arrayOfInt = new int[2];
    arrayOfInt[0] = localDisplay.getWidth();
    arrayOfInt[1] = localDisplay.getHeight();
    return arrayOfInt;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.app.PrisApp
 * JD-Core Version:    0.6.0
 */